<template>
	<view>
		<!-- #FA9700 -->
		<view>
			<u-navbar :border-bottom="false" :is-fixed="true" back-icon-color="#fff" title-color="#fff"
				:background="background" :title="form.title">
				<view @click="go" slot="right" style="margin-right: 20px; color: #fff;">
					{{form.type==1?'绑定账号':'奖励说明'}}
				</view>
			</u-navbar>
			<view style="width: 100%; height: 120px; background: #FA9700; border-radius: 0 0 25% 25%; ">

			</view>
			<view
				style="width: 95%;flex-flow: column; display: flex; justify-content: center; background: #fff; text-align: center; border-radius: 14px; margin:-60px auto 0 auto;  padding: 20px 0; line-height: 30px;">
				<view style="width: 100%; font-size: 18px; font-weight: bold;">
					<view v-if="form.type==1"><text style="font-size: 12px;">¥</text>{{userInfo.money}}</view>
					<view v-else>
						{{tuanNum}}
					</view>
				</view>
				<view style="width: 100%; color: #999;">
					{{form.type==1?'我的余额':'团队成员'}}
				</view>
				<view style="width: 100%;">
					<u-button shape="circle" type="warning" size="medium" @click="goPages" >
						{{form.type==1?'提现':'邀请好友'}}</u-button>
				</view>
			</view>
			<view v-if="form.type==1" class="content" style="box-sizing: border-box; padding: 10px;">
				<!-- 正文内容 -->
				<view style="border-radius: 12px; background: #fff;border-radius: 14px; overflow: hidden;">
					<view style="padding: 20px 0;">
						<u-section @click="click" title="余额明细" sub-title="更多"></u-section>
					</view>
					<view-NoData v-if="priceArray.length==0">
						
					</view-NoData>
					<view>
						<u-cell-group v-for="(items,indexs) in priceArray" :key="indexs">
							<u-cell-item :title="items.memo"  :arrow="false">
								<view style="color: #FD8521;" slot="right-icon">
									{{items.type}}{{items.money}}
								</view>
							</u-cell-item>
						</u-cell-group>
					</view>
				</view>
			</view>
			<view style="box-sizing: border-box; padding: 10px;" v-else>
				<view style="border-radius: 12px; background: #fff;border-radius: 14px; overflow: hidden;">
					<view style="display: flex; line-height: 40px;">
						<view style="margin-left: 20px;">
							成员列表
						</view>
						<!-- <view style="margin-left: 20px;">
							收益明细
						</view> -->
					</view>
					<view-NoData v-if="tuanList.length==0">
						
					</view-NoData>
					<u-cell-group>
						<u-cell-item v-for="(itemed,indexed) in tuanList" :key="indexed"   :title="itemed.nickname" :arrow="false">
							<!-- <u-icon slot="icon" size="32" name="search"></u-icon> -->
							<view slot="icon">
								<image style="width: 50px; height: 50px;" :src="itemed.avatar"></image>
							</view>
							<view slot="right-icon" @click="changeTuan(itemed)">
								{{itemed.createtime}} 注册
							</view>
						</u-cell-item>
					</u-cell-group>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getUserInfo,
		yuprice,
		getLists
	} from "@/common/config/request.js"
	export default {
		data() {
			return {
				form: {},
				userInfo: "", //用户详情
				background: {
					backgroundColor: '#FA9700',
				},
				customStyle: {
					width: '120px',
					backgroundColor: '#FA9700',
					marginTop: '20px', // 注意驼峰命名，并且值必须用引号包括，因为这是对象
					color: '#fff'
				},
				priceArray: [], //余额明细
				tuanNum: "", //团队总数
				tuanList: [], //团队列表
			}
		},
		onLoad(e) {
			this.form.title = e.title
			this.form.type = e.type
			// uni.setNavigationBarTitle({
			// 	title:e.title
			// })
		},
		onShow() {
			this.getInfo()
			this.getYuPrice()
			this.getListed() //我的团队
		},
		methods: {
			changeTuan(e){
				console.log(e)
				uni.navigateTo({
					url:'/pages/purse/tuanDetail?user_id='+e.id
				})
				// 点击团队列表
			},
			getListed() {
				getLists({}).then(res => {
					// console.log(res, '我的团队')
					if (res.data.code == 1) {
						this.tuanNum = res.data.data.total
						this.tuanList = res.data.data.list
						// console.log(this.tuanList, 'this.tuanList')
					}
				})
			},
			getYuPrice() {
				yuprice({}).then(res => {
					// console.log(res,'余额明细')
					if (res.data.code == 1) {
						this.priceArray = res.data.data.data
						// console.log(this.priceArray)
					}
				})
			},
			getInfo() {
				// 用户详情
				getUserInfo({}).then(res => {
					if (res.data.code == 1) {
						this.userInfo = res.data.data
					}
				})
			},
			// 提现
			goPages() {
				if (this.form.type == 1) {
					uni.navigateTo({
						url: '/pages/purse/distill?moeney=' + this.userInfo.money+"&withdraw="+this.userInfo.withdraw
					})
				}else{
					uni.navigateTo({
						url:'/pages/purse/enroll'
					})
				}
			},
			go() {
				if (this.form.type == 1) {
					uni.navigateTo({
						url: './bindZhang'
					})
				} else {
					uni.navigateTo({
						url: '/pages/public/public?title=奖励说明&id=3'
					})
				}
			},
			click() {
				uni.navigateTo({
					url: './details'
				})
			},
		}
	}
</script>

<style>
	page {
		background: #f0f0f0;
	}
</style>
